package com.ssy.lingxi.member.merchant.repository;


import com.ssy.lingxi.member.merchant.entity.MemberBusinessTypeDO;
import com.ssy.lingxi.member.merchant.entity.MemberTypeDO;
import com.ssy.lingxi.member.merchant.entity.RoleDO;
import com.ssy.lingxi.member.merchant.entity.RoleTypeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 业务平台 - 角色数据库操作JpaRepository
 * @author 万宁
 * @date 2020-06-15
 * @version 2.0.0
 */
@Repository
public interface RoleRepository extends JpaRepository<RoleDO, Long>, JpaSpecificationExecutor<RoleDO> {
    boolean existsByRoleName(String roleName);

    boolean existsByRoleNameAndIdNot(String roleName, long id);

    boolean existsByBusinessTypeAndMemberTypeAndStatus(MemberBusinessTypeDO businessTypeDO, MemberTypeDO memberType, Integer status);

    RoleDO findFirstByBusinessTypeAndMemberTypeAndRelTypeNotAndStatus(MemberBusinessTypeDO businessTypeDO, MemberTypeDO memberType, Integer relType, Integer status);

    List<RoleDO> findByMemberType(MemberTypeDO memberTypeDO);

    RoleDO findFirstByRelType(Integer relType);

    List<RoleDO> findByRoleType(RoleTypeDO roleTypeDO);
}
